package com.immunology.servlets;

import java.io.IOException;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.immunology.model.Complaint;
import com.immunology.model.MappingPages;
import com.immunology.service.ComplaintService;

public class AddSyndromeSurveyServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public AddSyndromeSurveyServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// getServletContext().getRequestDispatcher(MappingPages.SHOW_SURVEY_JSP)
		// .forward(request, response);
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		Map<String, Map<String, List<Complaint>>> syndromeMap = null;
		@SuppressWarnings("unchecked")
		Enumeration<String> enumeration = request.getParameterNames();
		int syndromeId = Integer.parseInt(enumeration.nextElement());
		ComplaintService complaintService = ComplaintService.getInstance();
		syndromeMap = complaintService.getComplaintListBySyndromeId(syndromeId);
		request.setAttribute("syndromeMap", syndromeMap);
		getServletContext().setAttribute("syndromeId", syndromeId);
		request.getRequestDispatcher(MappingPages.ADD_SURVEY_JSP).forward(
				request, response);

	}

}
